package com.example.base.security.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.example.base.system.domain.SysApi;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/6/11 14:39
 * @since JDK 1.8
 */
@Data
@TableName("sys_menu")
public class SysMenuEntity extends DataBase implements Serializable {

    private static final long serialVersionUID = 1L;


    /**
     * 权限ID
     */
    @JSONField(name = "id")
    @TableId(type = IdType.AUTO)
    private Integer menuId;
    /**
     * 权限名称
     */
    @JSONField(serialize = false, deserialize = false)
    private String name;
    /**
     * 权限标识
     */
    @JSONField(name = "name")
    private String permission;

    @JSONField(name = "path")
    @ApiModelProperty("菜单路径")
    private String path;

    @JSONField(name = "component")
    @ApiModelProperty("菜单组件")
    private String component;

    @JSONField(serialize = false, deserialize = false)
    @ApiModelProperty("菜单图标")
    private String menuIcon;

//    @JSONField(serialize = false, deserialize = false)
    @ApiModelProperty("菜单名称")
    private String menuName;

    @JSONField(name = "parentId")
    @ApiModelProperty("父菜单id")
    private Integer parentMenuId;

    @JSONField(serialize = false, deserialize = false)
    @ApiModelProperty("菜单类型")
    private String menuType;

    @JSONField(serialize = false, deserialize = false)
    private String menuAffix;

    @JSONField(serialize = false, deserialize = false)
    @ApiModelProperty("菜单标签")
    private String menuTag;

    @TableField(exist = false)
    @JSONField(name = "children")
    private List<SysMenuEntity> child;

    @TableField(exist = false)
    private Meta meta;

    @JSONField(serialize = false, deserialize = false)
    @ApiModelProperty("菜单颜色")
    private String menuColor;

    @JSONField(serialize = false, deserialize = false)
    @ApiModelProperty("菜单是否隐藏")
    private Boolean menuHidden;

    @JSONField(serialize = false, deserialize = false)
    @ApiModelProperty("菜单是否整页路由")
    private Boolean menuFullpage;

    @JSONField(serialize = false, deserialize = false)
    @ApiModelProperty("菜单高亮")
    private String menuActive;

    @JSONField(name = "redirect")
    @ApiModelProperty("菜单重定向")
    private String menuRedirect;


    public Meta getMeta() {
        if(meta==null){
            meta=new Meta(this.menuName,this.menuIcon,this.menuType,this.menuTag,
                    this.menuColor,this.menuFullpage,this.menuHidden,this.menuActive);
        }
        return meta;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    class Meta{

        private String title;

        private String icon;

        private String type;

        private String tag;

//        private String affix;

        private String color;

        private Boolean fullpage;

        private Boolean hidden;

        private String active;

//        public String getTitle() {
//            return title;
//        }
//
//        public void setTitle(String title) {
//            this.title = title;
//        }
//
//        public String getIcon() {
//            return icon;
//        }
//
//        public void setIcon(String icon) {
//            this.icon = icon;
//        }
//
//        public String getType() {
//            return type;
//        }
//
//        public void setType(String type) {
//            this.type = type;
//        }
//
//        public String getTag() {
//            return tag;
//        }
//
//        public void setTag(String tag) {
//            this.tag = tag;
//        }
//
////        public String getAffix() {
////            return affix;
////        }
////
////        public void setAffix(String affix) {
////            this.affix = affix;
////        }
//
//        public String getColor() {
//            return color;
//        }
//
//        public void setColor(String color) {
//            this.color = color;
//        }
//
//        public Boolean getFullpage() {
//            return fullpage;
//        }
//
//        public void setFullpage(Boolean fullpage) {
//            this.fullpage = fullpage;
//        }
//
//        public Boolean getHidden() {
//            return hidden;
//        }
//
//        public void setHidden(Boolean hidden) {
//            this.hidden = hidden;
//        }
//
//        public String getActive() {
//            return active;
//        }
//
//        public void setActive(String active) {
//            this.active = active;
//        }
//
////        public Meta(String title, String icon, String type, String tag, String affix, String color, Boolean fullpage, Boolean hidden, String active) {
////            this.title = title;
////            this.icon = icon;
////            this.type = type;
////            this.tag = tag;
////            this.affix = affix;
////            this.color = color;
////            this.fullpage = fullpage;
////            this.hidden = hidden;
////            this.active = active;
////        }
    }

}
